Column

Chart A

Column

Chart B

Chart C

---
title: "Dashboard"
output: 
  flexdashboard::flex_dashboard:
    orientation: columns
    vertical_layout: fill
    source: embed
---

```{r setup, include=FALSE}
library(flexdashboard)
```

Column {data-width=650}
-----------------------------------------------------------------------

```{r, echo = FALSE, message = FALSE}
library(p8105.datasets)
library(tidyverse)
library(plotly)

```

```{r}
data("nyc_airbnb")

nyc_airbnb =
  nyc_airbnb %>% 
  mutate(rating = review_scores_location / 2) %>% 
  select(neighbourhood_group, neighbourhood, rating, price, room_type, lat, long) %>% 
  filter(
    neighbourhood_group == 'Manhattan',
    price %in% 100:500,
    room_type == "Entire home/apt"
  ) %>% 
  drop_na(rating)
```

### Chart A

```{r}
nyc_airbnb %>% 
  mutate(
    text_label = str_c("Price: $", price, "\nRating: ", rating)) %>%
  plot_ly(
    x= ~lat, y= ~long, color = ~price, text = ~text_label,
    alpha = 0.5, type = "scatter", mode = "markers")
```

Column {data-width=350}
-----------------------------------------------------------------------

### Chart B

```{r}
nyc_airbnb %>% 
  mutate(neighbourhood = fct_reorder(neighbourhood, price)) %>% 
  plot_ly(y= ~price, x= ~neighbourhood, type = "box", color = ~neighbourhood, colors = "viridis")
```

### Chart C

```{r}
nyc_airbnb %>% 
  count(neighbourhood) %>% 
  mutate(neighbourhood = fct_reorder(neighbourhood, n)) %>% 
  plot_ly(
    x = ~neighbourhood, y= ~n, color = ~neighbourhood, 
    type = "bar", colors = "viridis")
```